home *** CD-ROM | disk | FTP | other *** search
- Path: io.org!jgordon
- From: jgordon@io.org (John Gordon MacPherson)
- Newsgroups: comp.lang.c
- Subject: Help with simple code
- Date: 14 Jan 1996 16:22:29 GMT
- Organization: Internex Online, Toronto, Ontario, Canada (416 363 3783)
- Distribution: world
- Message-ID: <4dbak5$oij@ionews.io.org>
- NNTP-Posting-Host: kipper.net2.io.org
- X-Newsreader: slrn (0.8.0)
-
- Can anyone tell me what's wrong with this piece of code? I lifted it
- straight from a textbook.
-
- Here's the code:
-
- /* Calculating compound interest */
- #include <stdio.h>
- #include <math.h>
-
- main()
- {
- int year;
- double amount, principal = 1000, rate = 0.5;
-
- printf("%4s%21s\n", "Year", "Amount on deposit");
-
- for (year = 1; year <= 10; year++) {
- amount = principal * pow(1.0 + rate, year);
- printf("%4d%21.2f\n", year, amount);
- }
-
- return 0;
- }
- ______________________________________________________________
-
- and here's the error:
-
- In function `main':
- undefined reference to `pow'
-
- I don't understand. `pow' is a function, not a variable?
- Can anyone tell me what's wrong?
-
-
-